home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 19 / Amiga Format CD19 (1997-10-02)(Future Publishing)(GB)(Track 1 of 5)[!][issue 1997-11].iso / -seriously_amiga- / shareware / workbench / dopus / archive / archive.lzh / Modules / Archive.dopus5
Text File  |  1997-08-10  |  9KB  |  286 lines

  1.  
  2.  
  3. /* path to temporary directory */
  4. TempDir           = "DH1:t/"
  5.  
  6.  
  7. /*
  8.  
  9. These lines describe the various crunchers and how to invoke them.
  10. The template is as follows:
  11.  
  12.  
  13. Cruncher.<number>.Name
  14.     The name of the cruncher. Can be any string without "|" characters.
  15.  
  16. Cruncher.<number>.ID
  17.     The cruncher's ID as used in the filetypes. You MUST have a filetype
  18.     with this ID if this script should be able to recognize archives of
  19.     this filetype.
  20.  
  21. Cruncher.<number>.Pack
  22.     Path and options for this cruncher (packing). If you specify ""
  23.     (including quotes) here, you can disable packing for this cruncher.
  24.  
  25. Cruncher.<number>.Unpack
  26.     Path and options for this cruncher (unpacking). If you specify ""
  27.     (including quotes) here, you can disable unpacking for this cruncher.
  28.  
  29. Cruncher.<number>.Suffix
  30.     The usual archive suffix for archives of this cruncher (eg. ".lha",
  31.     ".lzx" and so on).
  32.  
  33. Cruncher.<number>.Quotes
  34.     If you specify "yes" here (without quotes), you can tell the script
  35.     that this cruncher accepts quotes in file names.
  36.  
  37.     Set this to "no" (without quotes), if it doesn't.
  38.  
  39.  
  40. Notes: - Cruncher #1 is the default cruncher. That means you can immediately
  41.          use it to crunch archives by pressing <Return> in the requester.
  42.        - Cruncher numbers start with 1!
  43.  
  44. */
  45. Cruncher.1.Name   = "LZX"
  46. Cruncher.1.ID     = "LZX"
  47. Cruncher.1.Pack   = "LZX -3 -r -x -e -a -Y -X0 -w" || TempDir || " a --"
  48. Cruncher.1.Unpack = "LZX -m -X0 -w" || TempDir || " x --"
  49. Cruncher.1.Suffix = ".lzx"
  50. Cruncher.1.Quotes = yes
  51.  
  52. Cruncher.2.Name   = "LhA"
  53. Cruncher.2.ID     = "LHA"
  54. Cruncher.2.Pack   = "LhA -2 -r -x -e -a -Z -X -w" || TempDir || " a -Qo"
  55. Cruncher.2.Unpack = "LhA -m -M -X -w" || TempDir || " x -Qo"
  56. Cruncher.2.Suffix = ".lha"
  57. Cruncher.2.Quotes = yes
  58.  
  59. Cruncher.3.Name   = "LhArc"
  60. Cruncher.3.ID     = "LZH"
  61. Cruncher.3.Pack   = "LhA -0 -r -x -e -a -Z -X -w" || TempDir || " a -Qo"
  62. Cruncher.3.Unpack = "LhA -m -M -X -w" || TempDir || " x -Qo"
  63. Cruncher.3.Suffix = ".lzh"
  64. Cruncher.3.Quotes = yes
  65.  
  66. Cruncher.4.Name   = "LhArc (store)"
  67. Cruncher.4.ID     = ""
  68. Cruncher.4.Pack   = "LhA -z -r -x -e -a -X -w" || TempDir || " a -Qo"
  69. Cruncher.4.Unpack = ""
  70. Cruncher.4.Suffix = ".lzh"
  71. Cruncher.4.Quotes = yes
  72.  
  73. Cruncher.5.Name   = "LhASFX"
  74. Cruncher.5.ID     = "LHASFX"
  75. Cruncher.5.Pack   = ""
  76. Cruncher.5.Unpack = "LhA -m -M -X -w" || TempDir || " x -Qo"
  77. Cruncher.5.Suffix = ".run"
  78. Cruncher.5.Quotes = yes
  79.  
  80. Cruncher.6.Name   = "PKZip"
  81. Cruncher.6.ID     = "ZIP"
  82. Cruncher.6.Pack   = "Zip -r -k -g -9"
  83. Cruncher.6.Unpack = "UnZip -o"
  84. Cruncher.6.Suffix = ".zip"
  85. Cruncher.6.Quotes = no
  86.  
  87.  
  88.  
  89.  
  90. /************ PLEASE DO NOT CHANGE ANYTHING BELOW THIS LINE ************/
  91.  
  92. /*
  93. $VER: Archive.dopus5 1.0 (11.8.97) © by Maik "BLiZZeR" Schreiber [Freeware]
  94. */
  95.  
  96.  
  97. LF = "0a"x
  98.  
  99. Signal ON SYNTAX
  100. Signal ON BREAK_C
  101.  
  102. Options RESULTS
  103. Options FAILAT 21
  104.  
  105. Parse ARG DOpusPort function source dummy .
  106.  
  107. Address VALUE DOpusPort
  108.  
  109. If (function = "init") Then
  110.   Call init
  111. Else If (function = "PackArc") Then
  112.   Call PackArc
  113. Else If (function = "UnpackArc") Then
  114.   Call UnpackArc
  115. Call Quit
  116.  
  117.  
  118. init: Procedure
  119. 'dopus command "PackArc" program "Archive" desc "Packs archives" source'
  120. 'dopus command "UnpackArc" program "Archive" desc "Unpacks archives" source'
  121. Return
  122.  
  123.  
  124. PackArc:
  125. 'lister query ' || source || ' numseldirs'
  126. seldirs = RESULT
  127. If (seldirs < 1) Then
  128.   Return
  129. 'lister query ' || source || ' numentries'
  130. entries = RESULT
  131. 'lister query ' || source || ' path'
  132. sourcepath = Strip(RESULT, "B", '"')
  133. 'lister set ' || source || ' busy 1'
  134. gads = ""
  135. Do dummy = 1 WHILE (Cruncher.dummy.Name ~= ("CRUNCHER." || dummy || ".NAME"))
  136.   If (Cruncher.dummy.Pack ~= "") Then
  137.     gads = gads || Cruncher.dummy.Name || "|"
  138. End
  139. gads = gads || "Abbruch"
  140. 'lister request ' || source || ' "Which cruncher do you want to use?" ' || gads
  141. curr_cruncher = RC
  142. If (curr_cruncher ~= 0) Then
  143. Do
  144.   dummy = 0
  145.   Do dummy2 = 1 WHILE (Cruncher.dummy2.Name ~= ("CRUNCHER." || dummy2 || ".NAME"))
  146.     If (Cruncher.dummy2.Pack ~= "") Then
  147.       dummy = dummy + 1
  148.     If (dummy = curr_cruncher) Then
  149.       Break
  150.   End
  151.   curr_cruncher = dummy2
  152.  
  153.   If (curr_cruncher ~= 0) Then
  154.   Do
  155.     'lister set ' || source || ' newprogress name file info bar abort'
  156.     'lister set ' || source || ' newprogress title Creating archives...'
  157.     'lister set ' || source || ' newprogress info Cruncher: ' || Cruncher.curr_cruncher.Name
  158.     curr_dir = 1
  159.     Do dummy = 0 TO (entries - 1)
  160.       'lister query ' || source || ' abort'
  161.       If (RESULT = 1) Then
  162.         Break
  163.       'lister query ' || source || ' entry #' || dummy || ' stem SOURCEFILE'
  164.       If ((sourcefile.type > 0) & (sourcefile.selected = 1)) Then
  165.       Do
  166.         'lister set ' || source || ' newprogress name ' || sourcefile.name || Cruncher.curr_cruncher.Suffix
  167.         'lister set ' || source || ' newprogress file ' || seldirs || " " || curr_dir
  168.         'lister set ' || source || ' newprogress bar ' || seldirs || " " || curr_dir
  169.         If (Cruncher.curr_cruncher.Quotes = yes) Then
  170.           quote = '"'
  171.         Else
  172.           quote = ""
  173.         Pragma("D", sourcepath || sourcefile.name)
  174.         Address COMMAND Cruncher.curr_cruncher.Pack || " " || quote || sourcepath || sourcefile.name || Cruncher.curr_cruncher.Suffix || quote || " *"
  175.         ret = RC
  176.         Pragma("D", sourcepath)
  177.         If (ret = 0) Then
  178.           Address COMMAND 'Delete >NIL: "' || sourcepath || sourcefile.name || '" ALL FORCE'
  179.         Else
  180.         Do
  181.           Address COMMAND 'Delete >NIL: "' || sourcepath || sourcefile.name || Cruncher.curr_cruncher.Suffix || '" FORCE'
  182.           'lister request ' || source || ' "Errors creating archive' || LF || sourcepath || sourcefile.name || Cruncher.curr_cruncher.Suffix || '!"'
  183.         End
  184.         curr_dir = curr_dir + 1
  185.       End
  186.     End
  187.     'lister clear ' || source || ' progress'
  188.     'lister set ' || source || ' busy 0'
  189.     'lister read ' || source || ' "' || sourcepath || '" force'
  190.   End
  191. End
  192. 'lister set ' || source || ' busy 0'
  193. Return
  194.  
  195.  
  196. UnpackArc:
  197. 'lister query ' || source || ' numselfiles'
  198. selfiles = RESULT
  199. If (selfiles < 1) Then
  200.   Return
  201. 'lister query ' || source || ' numentries'
  202. entries = RESULT
  203. 'lister query ' || source || ' path'
  204. sourcepath = Strip(RESULT, "B", '"')
  205. 'lister set ' || source || ' busy 1'
  206. 'lister set ' || source || ' newprogress name file info bar abort'
  207. 'lister set ' || source || ' newprogress title Decrunching archives...'
  208. curr_arc = 1
  209. Do dummy = 0 TO (entries - 1)
  210.   'lister query ' || source || ' abort'
  211.   If (RESULT = 1) Then
  212.     Break
  213.   'lister query ' || source || ' entry #' || dummy || ' stem SOURCEFILE'
  214.   If ((sourcefile.type < 0) & (sourcefile.selected = 1)) Then
  215.   Do
  216.     curr_cruncher = get_cruncher(sourcepath || sourcefile.name)
  217.     'lister set ' || source || ' newprogress name ' || sourcefile.name
  218.     'lister set ' || source || ' newprogress file ' || selfiles || " " || curr_arc
  219.     If (curr_cruncher ~= 0) Then
  220.       cruncher_name = Cruncher.curr_cruncher.Name
  221.     Else
  222.       cruncher_name = "«unknown»"
  223.     'lister set ' || source || ' newprogress info Cruncher: ' || cruncher_name
  224.     'lister set ' || source || ' newprogress bar ' || selfiles || " " || curr_arc
  225.     If (curr_cruncher ~= 0) Then
  226.     Do
  227.       If (Cruncher.curr_cruncher.UnPack ~= "") Then
  228.       Do
  229.         dir = sourcepath || sourcefile.name
  230.         dir = Left(dir, Length(dir) - Length(Cruncher.curr_cruncher.Suffix))
  231.         Address COMMAND 'MakeDir >NIL: "' || dir || '"'
  232.         If (RC = 0) Then
  233.         Do
  234.           If (Cruncher.curr_cruncher.Quotes = yes) Then
  235.             quote = '"'
  236.           Else
  237.             quote = ""
  238.           Pragma("D", dir)
  239.           Address COMMAND Cruncher.curr_cruncher.Unpack || " " || quote || sourcepath || sourcefile.name || quote
  240.           ret = RC
  241.           Pragma("D", sourcepath)
  242.           If (ret = 0) Then
  243.             Address COMMAND 'Delete >NIL: "' || sourcepath || sourcefile.name || '" FORCE'
  244.           Else
  245.           Do
  246.             Address COMMAND 'Delete >NIL: "' || dir || '" FORCE'
  247.             'lister request ' || source || ' "Errors decrunching archive' || LF || sourcepath || sourcefile.name || '!"'
  248.           End
  249.         End
  250.       End
  251.     End
  252.     curr_arc = curr_arc + 1
  253.   End
  254. End
  255. 'lister clear ' || source || ' progress'
  256. 'lister set ' || source || ' busy 0'
  257. 'lister read ' || source || ' "' || sourcepath || '" force'
  258. Return
  259.  
  260.  
  261. get_cruncher:
  262. Parse ARG get_cruncher_file
  263. 'dopus getfiletype "' || get_cruncher_file || '" id'
  264. get_cruncher_id = RESULT
  265. get_cruncher_num = 0
  266. Do cruncher_num = 1 WHILE (Cruncher.cruncher_num.Name ~= ("CRUNCHER." || cruncher_num || ".NAME"))
  267.   If (Cruncher.cruncher_num.ID = get_cruncher_id) Then
  268.   Do
  269.     get_cruncher_num = cruncher_num
  270.     Break
  271.   End
  272. End
  273. Return get_cruncher_num
  274.  
  275.  
  276. SYNTAX:
  277. BREAK_C:
  278. Address VALUE DOpusPort
  279. 'dopus request "Error in ARexx script' || LF || "Archive.dopus5," || LF || "Line " || SIGL || ":" || LF || LF || ErrorText(RC) || '"'
  280. Call Quit
  281.  
  282.  
  283. Quit:
  284. Exit
  285.  
  286.